Skip to content

update Ex: 9.27 instruction to use Zod library#3856

Closed
EledenGreen wants to merge 1 commit intofullstack-hy2020:sourcefrom
EledenGreen:patch-14
Closed

update Ex: 9.27 instruction to use Zod library#3856
EledenGreen wants to merge 1 commit intofullstack-hy2020:sourcefrom
EledenGreen:patch-14

Conversation

@EledenGreen
Copy link
Copy Markdown
Contributor

Updated instruction in Exercise: 9.27 .

instead of writing custom validator :

const parseDiagnosisCodes = (object: unknown): Array<Diagnosis['code']> =>  {
  if (!object || typeof object !== 'object' || !('diagnosisCodes' in object)) {
    // we will just trust the data to be in correct form
    return [] as Array<Diagnosis['code']>;
  }

  return object.diagnosisCodes as Array<Diagnosis['code']>;
};

using Zod library instead:

const DiagnosisCodesSchema = z
  .array(z.string())
  .optional()
  .transform((codes) => (codes ? codes : []));

@vejol vejol added the part 9 label Jan 3, 2025
@mluukkai
Copy link
Copy Markdown
Contributor

mluukkai commented Apr 7, 2026

fixed in new material

@mluukkai mluukkai closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants